package org.springframework.android.basicauth;

import org.springframework.amqp.core.MessageProperties;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.amqp.support.converter.SimpleMessageConverter;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class PruebaMain {

	/**
	 * @param args
	 * @throws InterruptedException 
	 */
	public static void main(String[] args) throws InterruptedException {
	    AbstractApplicationContext ctx =
	            new ClassPathXmlApplicationContext("context.xml");
	        RabbitTemplate template = ctx.getBean(RabbitTemplate.class);
	        
            MessageProperties messageProperties = new MessageProperties();
            messageProperties.setHeader("telefono", "1541663027"); 
            
            MessageConverter converter= new SimpleMessageConverter(); 
 
            MyMessage myMessage = new MyMessage("Estamos haciendo una prueba");
            
            org.springframework.amqp.core.Message message = converter.toMessage("Que buenaaaa onda", messageProperties);

            template.convertAndSend(message);
	        
	        Thread.sleep(1000);
	        ctx.destroy();
	}

}
